<script setup lang="ts">

const option=ref<ECOption>({
  title: {
    text: '顺风车用户车主认证统计',
    subtext: '司机认证信息',
    left: 'center'
  },
  tooltip: {
    trigger: 'item'
  },
  legend: {
    orient: 'vertical',
    left: 'left'
  },
  series: [
    {
      name: '数量：',
      type: 'pie',
      radius: '50%',
      data: [
        { value: 0, name: '已认证（司机）' },
        { value: 0, name: '未认证（乘客）' },
        // { value: 580, name: 'Email' },
        // { value: 484, name: 'Union Ads' },
        // { value: 300, name: 'Video Ads' }
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
})
onMounted(function (){
  cFetch<any[]>('/statistics/role',{
    auth:true,
    defaultOpts:{
      method:"GET",
    }
  }).then(res=>{
    if(res.code===200){
      let data=res.data
      console.log(data)
      if(data[0].role===1){
        change1(data[0].amount)
        change0(data[1].amount)
      }else{
        change0(data[0].amount)
        change1(data[1].amount)
      }

    }
  })
})
function change1(va:number){
  option.value.series[0].data[0].value=va
}
function change0(va:number){
  option.value.series[0].data[1].value=va
}
</script>

<template>
<VChart :option="option"/>
</template>

<style scoped lang="scss">

</style>